package com.demo.spring.aiservice;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.service.AiServices;

@Configuration
public class CommonConfig {
	
	@Autowired
	private OpenAiChatModel model;
	
	// 也可以通过直接在ConsultantService接口上加注解@AiService来实现，默认会直接注入OpenAiChatModel
	@Bean
	public ConsultantService consultantService() {
		ConsultantService consultantService = AiServices.builder(ConsultantService.class)
			.chatModel(model)
			.build();
		return consultantService;
	}

}
